home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / emacs.lha / emacs-19.16 / vms / logout.com < prev    next >
Text File  |  1992-11-06  |  3KB  |  92 lines

  1. $! Roland Blaine Roberts (roberts@curie.nsrl.rochester.edu)
  2. $! Nuclear Structure Research Laboratory
  3. $! University of Rochester
  4. $! Monday, 11 July 1988
  5. $!
  6. $! Command procedure to logout "safely".  The logout is aborted unless the
  7. $! current process has no subprocesses.
  8. $!
  9. $! Arguments:
  10. $!   p1 "KILL" means logout regardless of subprocesses.  If this is specified,
  11. $!      the subprocesses are stopped before attempting to logout.  (Under one
  12. $!      release of VMS v5, the subprocesses would not automatically be stopped
  13. $!      and UIS windows would hang.)
  14. $!
  15. $!
  16. $ set noon
  17. $ on control_y then continue
  18. $ verify = f$verify(0)
  19. $ privileges = f$setprv("NOWORLD,NOGROUP")
  20. $ ding[0,8] = 7
  21. $ err := write sys$error
  22. $ on control_y then goto abort
  23. $!
  24. $! Check for the existence of subprocecess before allowing logout.
  25. $! Loop through the process list to find out if the emacs process exists.
  26. $!
  27. $ ctx  = 0
  28. $ me   = f$process ()
  29. $ mid  = ""
  30. $ whoami:
  31. $   pid  = f$pid(ctx)
  32. $   proc = f$getjpi(pid,"PRCNAM")
  33. $   if proc .eqs. me 
  34. $   then mid = pid
  35. $   else goto whoami
  36. $   endif
  37. $ me   = mid
  38. $ ctx  = 0
  39. $ oops = 0
  40. $ loop:
  41. $   pid   = f$pid(ctx)
  42. $   proc  = f$getjpi(pid,"PRCNAM")
  43. $   mode  = f$getjpi(pid,"MODE")
  44. $   owner = f$getjpi(pid,"OWNER")
  45. $   if pid .eqs. me
  46. $   then 
  47. $     if ctx .ne. 0
  48. $     then goto loop
  49. $     else goto oops
  50. $     endif
  51. $   endif
  52. $!   if proc .eqs. "" then goto oops
  53. $   if (p1 .eqs. "KILL")
  54. $   then 
  55. $     if ((pid.nes.me) .and. (mode.eqs."INTERACTIVE") .and. (owner.eqs.me))
  56. $     then    
  57. $       err "%LOGOUT-I-STOPPRC, Stopping subprocess ''pid' ""''proc'"""
  58. $       stop "''proc'"
  59. $     endif
  60. $   else
  61. $     if (pid.nes.me) .and. (mode.eqs."INTERACTIVE") .and. (owner.eqs.me)
  62. $     then
  63. $       if oops
  64. $       then err "-LOGOUT-W-PRCRUN, Subprocess ''pid' ""''proc'"" running!"
  65. $       else err "''ding'%LOGOUT-W-PRCRUN, Subprocess ''pid' ""''proc'"" running!"
  66. $       endif
  67. $       oops = 1
  68. $     endif
  69. $   endif
  70. $   if ctx .ne. 0 then goto loop
  71. $ oops:
  72. $   if oops
  73. $   then
  74. $     err "''ding'%LOGOUT-F-ABORT, Subprocesses are running"
  75. $     err "''ding'                 type LOGOUT KILL to logout anyway."
  76. $     set proc/privileges=( 'privileges' )
  77. $     if verify then set verify
  78. $     exit
  79. $   endif
  80. $!
  81. $! The command 'logout' is likely to be defined to this command procedure.
  82. $! Redefine it.
  83. $!
  84. $ logout:
  85. $   set symbol/scope=(noglobal,nolocal)
  86. $   logout/full/hangup
  87. $ abort:
  88. $   set process/privileges=( 'privileges' )
  89. $   if verify then set verify
  90. $   err "''ding'%LOGOUT-E-USRABORT, Logout aborted by user."
  91. $   exit
  92.